package com.pi.pro.xcmg.am.was.web.report;

/**
 *
 */

import com.pi.framework.core.util.DateUtils;
import com.pi.pro.xcmg.am.common.XcmgAmReportWorkSupport;
import com.pi.pro.xcmg.am.common.vo.report.*;
import com.pi.pro.xcmg.am.common.vo.sys.Result;
import com.pi.wms.service.KanbanReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.*;


/**
 * 报表(LED屏) 功能
 */
@Slf4j
@RestController("reportStorageReportContrller")
@RequestMapping("/api/wms/xcmg/report/kanban/storage")
public class ReportStorageController {

    @Autowired
    private KanbanReportService kanbanReportService;


    @RequestMapping(value="/summary",method = RequestMethod.POST)
    @ResponseBody
    public Result summary(@RequestBody ReportQueryDto queryParams){
        //
        Map<String, Object> query = new HashMap<>();
        query.put("divisioncode", queryParams.getDivisioncode());
        //
        StorageSummaryReportDto summaryInfo = null;
        summaryInfo =kanbanReportService.summaryStorageData(query);
        return new Result().success().data(summaryInfo);
    }

    @RequestMapping(value="/warehousesummary",method = RequestMethod.POST)
    @ResponseBody
    public Result warehousesummary(@RequestBody ReportQueryDto queryParams){
        //
        Map<String, Object> query = new HashMap<>();
        query.put("divisioncode", queryParams.getDivisioncode());
        //
        StorageWarehouseSummaryReportDto summaryInfo = null;
        summaryInfo =kanbanReportService.summaryStorageWarehouseData(query);
        return new Result().success().data(summaryInfo);
    }


    @RequestMapping(value="/lanesummary",method = RequestMethod.POST)
    @ResponseBody
    public Result lanesummary(@RequestBody ReportQueryDto queryParams){
        //
        Map<String, Object> query = new HashMap<>();
        query.put("divisioncode", queryParams.getDivisioncode());
        List<StorageLaneSummaryReportDto> lanes = null;
        lanes =kanbanReportService.summaryStorageLaneData(query);
        return new Result().success().data(lanes);
    }

    @RequestMapping(value="/stockeage",method = RequestMethod.POST)
    @ResponseBody
    public Result stockeage(@RequestBody ReportQueryDto queryParams){
        String m = "";
        //
        Map<String, Object> query = new HashMap<>();
        query.put("divisioncode", queryParams.getDivisioncode());
        StorageAgeSummaryReportDto summaryInfo = null;
        summaryInfo =kanbanReportService.summaryStorageAgeData(query);
        //summaryInfo = XcmgAmReportWorkSupport.mockStorageAgeSummaryReport();
        return new Result().success().data(summaryInfo);
    }

    @RequestMapping(value="/stockeagesumm",method = RequestMethod.POST)
    @ResponseBody
    public Result stockeageSummary(@RequestBody ReportQueryDto queryParams){
        String m = "";
        //
        Map<String, Object> query = new HashMap<>();
        query.put("divisioncode", queryParams.getDivisioncode());
        List<StorageAgeContainerSummaryReportDto> lines = new ArrayList<>();

        /**
        StorageAgeContainerSummaryReportDto d01=new StorageAgeContainerSummaryReportDto();
        d01.setType("A01");
        d01.setTypename("0-30");
        d01.setTotal(200);
        lines.add(d01);

        StorageAgeConsSummaryReportDto d02=new StorageAgeConsSummaryReportDto();
        d02.setType("A02");
        d02.setTypename("31-60");
        d02.setTotal(103);
        lines.add(d02);

        StorageAgeContainerSummaryReportDto d03=new StorageAgeContainerSummaryReportDto();
        d03.setType("A03");
        d03.setTypename("31-90");
        d03.setTotal(103);
        lines.add(d03);

        StorageAgeContainerSummaryReportDto d04=new StorageAgeContainerSummaryReportDto();
        d04.setType("A04");
        d04.setTypename("91-180");
        d04.setTotal(503);
        lines.add(d04);

        StorageAgeContainerSummaryReportDto d05=new StorageAgeContainerSummaryReportDto();
        d05.setType("A05");
        d05.setTypename("181-360");
        d05.setTotal(333);
        lines.add(d05);


        StorageAgeContainerSummaryReportDto d06=new StorageAgeContainerSummaryReportDto();
        d06.setType("A06");
        d06.setTypename("360-720");
        d06.setTotal(32);
        lines.add(d06);
        d05.setTotal(333);
        lines.add(d05);

        StorageAgeContainerSummaryReportDto d07=new StorageAgeContainerSummaryReportDto();
        d07.setType("A07");
        d07.setTypename("720+");
        d07.setTotal(5);
        lines.add(d07);
        **/

        lines = kanbanReportService.summaryStorageAgeContainerData(query);
        return new Result().success().data(lines);
    }


    @RequestMapping(value="/currenttime",method = RequestMethod.POST)
    @ResponseBody
    public Result currenttime(@RequestBody ReportQueryDto queryParams){
        String ctime= DateUtils.format(new Date(), DateUtils.FORMAT_DATE_YYYY_MM_DD_HH_MM_SS);
        return new Result().success().data(ctime);
    }


}
